<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@include file="/pageRc/common/common.jsp"%>

<!DOCTYPE html>
<html lang="en" style="overflow-x: hidden">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
	content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="msapplication-tap-highlight" content="no">

<link rel="stylesheet" href="<%=commonPath%>/pageRc/layui/css/layui.css"
	media="all">
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/common/utils.js"></script>
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/common/msgTool.js"></script>
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/layui/layui.js"></script>

<title>需求管理</title>

<script>
	$(function(){

 	})
	//注意：选项卡 依赖 element 模块，否则无法进行工能性操作
	layui.use('element', function() {
		var element = layui.element();

		//…
	});
</script>
<jsp:include page="publicMethod.jsp" />
</head>
<body class="layui-main" style="width: 100%;">
<input type="hidden" value="${positionType}" id="positionType">
	<blockquote class="layui-elem-quote">需求管理</blockquote>
		<form id="createMsgForm" name="createMsgForm" class="layui-form"
			action="">
			<div class="layui-form-item">
				<div class="layui-inline">
					<div class="layui-inline">
						<select name="proGroupNo" id="proGroupNo"
							lay-filter="proGroupSelect" style="width: 210;">
								<c:forEach items="${groupList}" var="group">
									<option value="${group.proGroupNo}">${group.proGroupName}</option>
								</c:forEach>
						</select>
					</div>
					<div class="layui-inline">
						<select name="proTeamNo" id="proTeamNo" style="width: 210;">
							<c:if test="${positionType=='70'}">
								  <c:forEach items="${teanList}" var="tean">
									<option value="${tean.proTeamNo}">${tean.proTeamName}</option>
								  </c:forEach>
							</c:if>
							<c:if test="${positionType!='70'}">
							<option value="">项目组名称</option>
							<option value="">全部</option>
							<c:forEach items="${teanList}" var="tean">
								<option value="${tean.proTeamNo}">${tean.proTeamName}</option>
							</c:forEach>
							</c:if>
						</select>
					</div>
					<div class="layui-inline">-</div>
					<div class="layui-inline">
						<button class="layui-btn" type="button" data-method="doSearchSum" id="doSearchSum" >查询</button>
						<button class="layui-btn" type="button" data-method="doExcel">excel下载</button>
						<button class="layui-btn" type="button" onclick="addNeed();">添加需求</button>
					</div>
				</div>
			</div>


			<div class="layui-form-item">
				<div class="layui-inline">
					<div class="layui-inline">
						<input class="layui-input"  id="needName"
							placeholder="需求名称">
					</div>
					<div class="layui-inline">
						<input class="layui-input" id="needNo"
							placeholder="需求编号">
					</div>
				</div>
			</div>
			<div class="layui-form-item" id="dateDiv">
				<div class="layui-inline">
					<table class="layui-table" lay-even="" lay-skin="line"
						style="text-align: center;width: 100%;">
						<colgroup align="center">
							<col width="10%">
							<col width="10%">
							<col width="5%">
							<col width="5%">
							<col width="10%">
							<col width="10%">
							<col width="10%">
							<col width="15%">
							<col width="10%">
							<col width="10%">
							<col width="15%">
							<col width="10%">
							<col width="10%">
							<col width="10%">
							<col width="10%">
							<col width="10%">
							<col width="10%">
							<col width="10%">
							<col width="10%">
							<col width="10%">
						</colgroup>
						<thead>
							<tr>
								<th>需求编号</th>
								<th>需求名称</th>
								<th>评估工时</th>
								<th>人月</th>
								<th>最新报工阶段</th>
								<th>需求状态</th>
								<th>行方经理</th>
								<th>行方业务人员</th>
								<th>规划状态</th>
								<th>合同批次</th>
								<th>合同号</th>
								<th>产品编号</th>
								<th>录入销售系统金额</th>
								<th>操作</th>
								<th>操作</th>
								<th>操作</th>
								<th>操作</th>
								<th>操作</th>
								<th>操作</th>
								<th>操作</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody id="detailDiv">

						</tbody>
						<script id="tplSrc" type="text/html">
							 {{#  layui.each(d.needList, function(index, x){}}
							     <tr align="left">
								   <td><a href="javascript:void(0)" onclick="StageByNeedId('{{x.rouid}}')"><u>{{x.needNo==undefined?'':x.needNo}}</u></a></td>
								   <td>{{x.needName==undefined?'':x.needName}}</td>
									<td>{{x.needTime==undefined?'':x.needTime}}</td>
									<td>{{x.renyue==undefined?'':x.renyue}}</td>
								    <td>{{x.stage==undefined?'<font color="red">暂无报功记录</font>':x.stage}}</td>
									<td>{{x.state==undefined?'':x.state=='01'?'正常':(x.state=='00'?'待审核':(x.state=='03'?'驳回':'需求关闭'))}}</td>
                                    <td>{{x.hfjl==undefined?'':x.hfjl}}</td>
									<td>{{x.hfywry==undefined?'':x.hfywry}}</td>
                                    <td>{{x.planStatus==undefined?'':x.planStatus}}</td>
									<td>{{x.contractApproval==undefined?'':x.contractApproval}}</td>
									<td>{{x.contractId==undefined?'':x.contractId}}</td>
									<td>{{x.contractNo==undefined?'':x.contractNo}}</td>
                                    <td>{{x.sale_Money==undefined?'':x.sale_Money}}</td>
									<td><button class="layui-btn" type="button" onclick="updateNeedInfor('{{x.rouid}}')" style="margin: 0px;display: {{x.state=='03'?'none':x.tiState=='0'?'block':'none'}}">更新</button></td>
                                    <td><button class="layui-btn" type="button" onclick="updateNeedstage('{{x.rouid}}')" style="margin: 0px;display: {{x.state=='03'?'none':x.tiState=='0'?'block':'none'}}">需求计划</button></td>
                                    <td><button class="layui-btn" type="button" onclick="onlineNeed('{{x.rouid}}','{{x.needTime}}')" style="margin: 0px;display: {{x.state=='00'?'none':x.state=='03'?'none':'block'}}">上线</button></td>
                                    <td><button class="layui-btn" type="button" onclick="saleNeedInfor('{{x.rouid}}','{{x.needTime}}')" style="margin: 0px;display: {{x.state=='00'?'none':x.state=='03'?'none':'block'}}">录入销售系统</button></td>
									<td><button  class="layui-btn" type="button" onclick="reStartNeedInfor('{{x.rouid}}')" style="margin: 0px;display: {{x.state=='02'?(x.white_Need=='1'?'block':'none'):'none'}}" >重新打开</button></td>
                                    <td><button  class="layui-btn" type="button" onclick="needLock('{{x.rouid}}')" style="margin: 0px;display: {{x.state=='03'?'none':x.sign=='0'?'block':'none'}}">锁定</button></td>
                                    <td><button  class="layui-btn" type="button" onclick="openLock('{{x.rouid}}')" style="margin: 0px;display: {{x.state=='03'?'none':x.sign=='1'?'block':'none'}}">解锁</button></td>
								    <td><button  class="layui-btn" type="button" onclick="deleteInfor('{{x.rouid}}')">删除</button></td>
								 </tr>
							{{#  }); }} 
					   </script>

					</table>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<div id="laypageDiv"></div>
				</div>
			</div><button style="margin: 0px;"></button>
		</form>
	</div>
	<input id="totalNum" type="hidden" name="totalNum" >
</body>
<script type="text/javascript">
var path="<%=commonPath%>";
	var msg = new msgTool();
	layui.use([ 'form', 'layer', 'laytpl', 'laypage', 'laydate' ],
	function() {
	var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
						var form = layui.form(), layer = layui.layer, laypage = layui.laypage, laytpl = layui.laytpl;
						var active = {
							doSearchSum : function() { //搜索
						      	     active.doSearchDetail(1); 
						        	 
						         }
						         ,doSearchDetail:function(v_curr){ //搜索   
						         if(v_curr==1){
						        	 var getTpl = tplSrc.innerHTML;
						  			var dataObj = {
						  						"startRow" : (v_curr-1)*15,
						  						"pageSize" : 15,
						  						"proTeamNo" : $("#proTeamNo").val(),
						  						"proGroupNo":$("#proGroupNo").val(),
						  						"needNo" : $("#needNo").val(),
						  						"needName" : $("#needName").val(),
						  					};
						  			msg.sendMsg("/page/need/searchNeedInforDetail.do",dataObj,function(data) {
						  				laytpl(getTpl).render(data.body,function(html) {
						  				    detailDiv.innerHTML = html;
						  					$('#totalNum').val(data.body.count)
						  				});
						  				totalNum = Math.ceil(data.body.count/15);
						  				laypage({
							                   cont: 'laypageDiv'
							                 ,pages:totalNum
							                  ,jump: function(obj,first){
							                	  if(first!=true){
							                	  	active.doSearchDetail(obj.curr); 
							                	  }
							                   }
							                 }); 
						  			}); 
						         }else{
						        	 var getTpl = tplSrc.innerHTML;
							  			var dataObj = {
							  						"startRow" : (v_curr-1)*15,
							  						"pageSize" : 15,
							  						"proTeamNo" : $("#proTeamNo").val(),
							  						"proGroupNo":$("#proGroupNo").val(),
							  						"needNo" : $("#needNo").val(),
							  						"needName" : $("#needName").val(),
							  					};
							  			msg.sendMsg("/page/need/searchNeedInforDetail.do",dataObj,function(data) {
							  				laytpl(getTpl).render(data.body,function(html) {
							  				    detailDiv.innerHTML = html;
							  					$('#totalNum').val(data.body.count)
							  				});
							  			}); 
						         }	
						         },
						         
						        
						     	doExcel : function() {
									var dataObj = {
										"proGroupNo" : $("#proGroupNo").val(),
										"proTeamNo" : $("#proTeamNo").val(),
										"needNo" : $("#needNo").val(),
										"needName" : $("#needName").val(),
									}
									msg.sendMsg("/page/main/doExcelNeedInfor.do",
											dataObj, function(data) {
												window.location.href = path
						+ "/downFile/"
						+ data.body.fileName
				});
			}
						         
						         
													
	}
	$('.layui-btn').on('click',function() {
		var othis = $(this), method = othis.data('method');
		active[method] ? active[method].call(this,othis) : '';
	});
});
	 function flush(){
	        $('#doSearchSum').click();
	    }
	 function updateNeedInfor(rouid) {
	        layer.open({
	            type: 2,
	            title:"需求更新",
	            area: ['65%', '95%'],
	            scrollbar: false,
	            content: '<%=commonPath %>/page/need/'+rouid+'/doUpdateNeedInfor.do',
	            success: function (layero, index) {
	            },
	            end: function () {
	            	flush();
	            }
	        });
	    }
	 
	 function StageByNeedId(rouid) {
			layer.open({
				type : 2,
				title : "需求计划信息",
				area : [ '95%', '95%' ],
				scrollbar : false,
				content : '<%=commonPath%>/page/main/' + rouid+ '/StageByNeedId.do',
				success : function(layero, index) {
				},
				end : function() {
				}
			});
		}
	 
	 function updateNeedstage(rouid) {
	        layer.open({
	            type: 2,
	            title:"需求计划更新",
	            area: ['60%', '95%'],
	            scrollbar: false,
	            content: '<%=commonPath %>/page/need/'+rouid+'/updateNeedstage.do',
	            success: function (layero, index) {
	            },
	            end: function () {
	            	flush();
	            }
	        });
	    }
	 
	 
	 function saleNeedInfor(rouid,needTime) {
		
	        layer.open({
	            type: 2,
	            title:"销售系统",
	            area: ['70%', '80%'],
	            scrollbar: false,
	            content: '<%=commonPath %>/page/need/'+rouid+'/'+needTime+'/doUpdateSaleNeed.do',
	            success: function (layero, index) {
	            },
	            end: function () {
	            	flush();
	            }
	        });
	 
	 }
	 
	 
	 function addNeed(){
		 
	        layer.open({
	            type: 2,
	            title:"新增需求",
	            area: ['70%', '80%'],
	            scrollbar: false,
	            content: '<%=commonPath %>/page/need/backdoMakeNeedback.do',
	            success: function (layero, index) {
	            },
	            end: function () {
	            	flush();
	            }
	        });
	 
	 }
	 
	 
	 function onlineNeed(rouid,needTime) {
			
	        layer.open({
	            type: 2,
	            title:"上线",
	            area: ['70%', '80%'],
	            scrollbar: false,
	            content: '<%=commonPath %>/page/need/'+rouid+'/'+needTime+'/doUpdateOnlineNeed.do',
	            success: function (layero, index) {
	            },
	            end: function () {
	            	flush();
	            }
	        });
	 
	 }
	 
	 
	 function deleteInfor(rouid) {
		 var jsonDate = {};
	        jsonDate.rouid = rouid;
		        msg.sendMsg("/page/need/dodeleteInfor.do", jsonDate, function (data) {
		            var rsObj = null;
		            if (msg.isJson(data)) {
		                rsObj = data
		            } else {
		                rsObj = JSON.parse(data);
		            }
		            var retCode = rsObj.head.retCode;
		            var message = rsObj.body.tishi;
		            if (retCode !== '0000') {
		                layer.alert("删除失败!");
		            } else {
		                flush();
		                layer.alert(message);
		            }
		        });
	    }
	 
	 
	 function needLock(rouid) {
		 var jsonDate = {};
	        jsonDate.rouid = rouid;
		        msg.sendMsg("/page/base/lockNeedInfor.do", jsonDate, function (data) {
		            var rsObj = null;
		            if (msg.isJson(data)) {
		                rsObj = data
		            } else {
		                rsObj = JSON.parse(data);
		            }
		            var retCode = rsObj.head.retCode;
		            if (retCode !== '0000') {
		                layer.alert("锁定失败！");
		            } else {
		                flush();
		                layer.alert("锁定成功！");
		            }
		        });
	    }
	 
	 
	 function openLock(rouid) {
	        var jsonDate = {};
	        jsonDate.rouid = rouid;
		        msg.sendMsg("/page/base/reOpenNeedInfor.do", jsonDate, function (data) {
		            var rsObj = null;
		            if (msg.isJson(data)) {
		                rsObj = data
		            } else {
		                rsObj = JSON.parse(data);
		            }
		            var retCode = rsObj.head.retCode;
		            if (retCode !== '0000') {
		                layer.alert("解锁失败！");
		            } else {
		                flush();
		                layer.alert("解锁成功！");
		            }
		        });
	    }
	 
	 
	 
	 
	 
	 
	 function reStartNeedInfor(rouid) {
	        var jsonDate = {};
	        jsonDate.rouid = rouid;
		        msg.sendMsg("/page/base/reStartNeedInfor.do", jsonDate, function (data) {
		            var rsObj = null;
		            if (msg.isJson(data)) {
		                rsObj = data
		            } else {
		                rsObj = JSON.parse(data);
		            }
		            var retCode = rsObj.head.retCode;
		            if (retCode !== '0000') {
		                layer.alert("打开失败！");
		            } else {
		                flush();
		                layer.alert("打开成功！");
		            }
		        });
	    }
	 
	 
</script>

</html>